<?php

//
// +------------------------------------------------------------------------+
// | PHP Version 5.4                                                        |
// +------------------------------------------------------------------------+
// | Copyright (c) 2015-2016 http://www.clcw.com.cn All rights reserved.    |
// +------------------------------------------------------------------------+
// | 世纪车来车往(北京）网络科技有限公司 版权所有！                               |
// | TEL:010-63732365  HOTLINE:400-6688-365  EMAIL:clcw@clcw.com.cn         |
// | $Revision: 1.0 $                                                       |
// +------------------------------------------------------------------------+
// | Author: Xmh <xiangminghu@clcw.com.cn>                                  |
// +------------------------------------------------------------------------+
//

namespace AuctionAppApi\Controller;

use Think\Controller;
use AuctionCore\Other\DealerFeedback;
use AuctionCore\System\AuctionException;

/**
 * 投诉建议API
 *
 * @author Xmh
 */
class FeedbackController extends BaseController {

    public function __construct() {
        parent::__construct();
        $this->dealer_id = I('param.dealer_id/d');
        if (empty($this->dealer_id)) {
            AuctionException::make_throw('500001');
        }
        $this->dealerfeedback = new DealerFeedback();
    }

    /**
     * 客户中心 - 投诉建议
     * 车商 - 投诉建议列表
     * return json 投诉建议列表
     */
    public function index() {
        $page = I('post.page/d', 1);
        $page_size = I('post.page_size/d', 20);
        $params = array(
            'df.dealer_id' => $this->dealer_id
        );
        $feedback_list = \AuctionCore\Other\DealerFeedback::app_dealer_feedback_list($page, $page_size, $params);
        $this->api_200($feedback_list);
    }

    /**
     * 客户中心 - 投诉建议
     * 车商 - 新增投诉建议
     * return json 新增投诉建议
     */
    public function add_feedback() {
        $data['dealer_id'] = $this->dealer_id;
        $data['type'] = I('post.type/d');
        $data['desc'] = I('post.desc/s');
        if(empty($data['desc'])){
            AuctionException::make_throw('900000');
        }
        $res = $this->dealerfeedback->add($data);
        if ($res) {
            $this->api_200("");
        } else {
            AuctionException::make_throw('100065');
        }
    }

}
